Skip to content

Conversation

@kanadgupta
Copy link
Member

rides the coattails of #271 with a few stricter return types and a little tsconfig.json cleanup.

@kanadgupta kanadgupta requested a review from erunion April 9, 2025 15:35
@kanadgupta kanadgupta changed the title refactor: stricter TS types, tsconfig cleanup refactor: stricter return types, tsconfig cleanup Apr 9, 2025
Base automatically changed from feat/isolated-declarations to main April 9, 2025 17:23
import { escapeString } from '../../helpers/escape.js';

export const convertType = (obj: any[] | any, indent?: string, lastIndent?: string): unknown => {
export const convertType = (obj: any[] | any, indent?: string, lastIndent?: string): string | 'null' => {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not just type this to string?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i kinda like when return types explicitly mention a value that's likely to show up, in case a downstream function wants to act on that value accordingly. no strong preferences on this though

"useUnknownInCatchVariables": false,

"strict": true
"verbatimModuleSyntax": true
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

haven't seen this one before, what's it do?

Copy link
Member Author

@kanadgupta kanadgupta Apr 9, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should probably enable it everywhere we can. it ensures that type imports use import type SomeType and not import SomeType, which will help us with treeshaking. as always mr. pocock has a good write-up on the subject in his cheat sheet: https://www.totaltypescript.com/tsconfig-cheat-sheet

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh cool

@kanadgupta kanadgupta merged commit 80ddf54 into main Apr 9, 2025
10 of 12 checks passed
@kanadgupta kanadgupta deleted the kanad-2025-04-09/more-ts-enhancements branch April 9, 2025 17:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants